<?php
/**
 * @orm tablename newsletter_blocks
 */
class NewsletterBlock_Basic extends NewsletterBlock {
	
	/**
	 * @orm text
	 */
	public $title;
	/**
	 * @orm longtext
	 */
	public $contents;
	/**
	 * @orm text
	 */
	public $readMoreLink;
	/**
	 * @orm plugin DomArImage({autoRename=1r})
	 * @orm listener afterAdd afterAddImage
	 */
	public $image;
	/**
	 * @orm char(10)
	 * @orm validator in({left,top,bottom,right,NULL})
	 */
	public $imagePosition = 'left';
	
	public function afterAddImage() {
		if( $this->image->exists() ) {
			$info = NewsLetter::getTemplateInfo($this->newsletter->template);
			if( $info['imageDefaultSizes'][$this->imagePosition]) {
				$size =  $info['imageDefaultSizes'][$this->imagePosition];
				$this->image->resize( $size[0], $size[1] );
			}
		}
	}
	
}
?>